var __extends =
    (this && this.__extends) ||
    (function () {
      var e = function (t, o) {
        return (e =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (e, t) {
              e.__proto__ = t;
            }) ||
          function (e, t) {
            for (var o in t)
              Object.prototype.hasOwnProperty.call(t, o) && (e[o] = t[o]);
          })(t, o);
      };
      return function (t, o) {
        function r() {
          this.constructor = t;
        }
        if ("function" != typeof o && null !== o)
          throw new TypeError(
            "Class extends value " + String(o) + " is not a constructor or null"
          );
        e(t, o),
          (t.prototype =
            null === o
              ? Object.create(o)
              : ((r.prototype = o.prototype), new r()));
      };
    })(),
  ScoredPointHomeView = (function (e) {
    function t() {
      var t = e.call(this) || this;
      return (
        (t.array = []),
        (t.rewardsListArr = []),
        (t.weekListArr = []),
        (t.currentViewName = ""),
        WebSocketService.addListener({
          caller: t,
          code: 5322,
          method: t.scoredDataHomeData,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 5324,
          method: t.scoredDataWeekData,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 5325,
          method: t.scoredDataWeekData,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 5323,
          method: t.scoredRewardResultData,
        }),
        t.btn_score_zhoubang.on(Laya.Event.CLICK, t, t.onDidLookZhouBangAction),
        t.btn_scoredPoint_back.on(Laya.Event.CLICK, t, t.onScoredPointedBackFn),
        t.btn_score_week_intro.on(
          Laya.Event.CLICK,
          t,
          t.onScoreWeekIntroAction
        ),
        t.tab_score_point.on(Laya.Event.CLICK, t, t.onTabScorePointAction),
        (t.list_today_score_reward.vScrollBarSkin = ""),
        (t.list_score_week_rank.vScrollBarSkin = ""),
        (t.list_score_point.vScrollBarSkin = ""),
        (t.list_today_score_reward.selectEnable = !0),
        t.list_today_score_reward.on(
          Laya.Event.CLICK,
          t,
          t.onDidRewardListClick
        ),
        (t.list_today_score_reward.renderHandler = new Handler(
          t,
          t.onRewardSelectedHandler
        )),
        t
      );
    }
    return (
      __extends(t, e),
      (t.showScoredPointHomeView = function () {
        return (
          null == this.scoredPointView && (this.scoredPointView = new t()),
          this.scoredPointView.initUI(),
          this.scoredPointView.initData(),
          this.scoredPointView
        );
      }),
      (t.prototype.initData = function () {
        (this.label_day_per.visible = !1),
          (this.label_week_per.visible = !1),
          (this.tab_score_point.visible = !1),
          "" == this.currentViewName
            ? ((this.label_day_per.visible = !0),
              WebSocketService.send({ c: 5322, d: { roleId: Global.roleId } }))
            : "view_week_rank" == this.currentViewName &&
              ((this.label_week_per.visible = !0),
              (this.tab_score_point.visible = !0),
              WebSocketService.send({ c: 5325, d: { roleId: Global.roleId } }));
      }),
      (t.prototype.initUI = function () {
        (this.list_score_week_rank.visible = !1),
          (this.list_today_score_reward.visible = !1),
          (this.list_score_point.visible = !1);
      }),
      (t.prototype.dealTodayReward = function () {
        if ("" == this.currentViewName) {
          var e = Constants.getScoreReward();
          this.rewardsListArr = [];
          for (var t = void 0, o = 0; o < e.length; o++) {
            var r = e[o];
            (t = { item_reward: { text: r.title }, score: r.score }),
              this.rewardsListArr.push(t);
          }
          (this.list_today_score_reward.visible = !0),
            (this.list_today_score_reward.dataSource = this.rewardsListArr);
        }
      }),
      (t.prototype.onDidLookZhouBangAction = function () {
        (this.currentViewName = "view_week_rank"),
          this.initData(),
          this.initUI();
      }),
      (t.prototype.scoredDataHomeData = function (e) {
        if (0 == e.code && e.data && e.more) {
          var t = e.more,
            o = e.data;
          (this.label_today_score.text = t.todayScore),
            (this.label_weekday_score.text = t.weekScore),
            (t.todayScore > 0 || t.weekScore > 0) &&
              (this.todayScore = t.todayScore),
            (this.array = []);
          (a = []).push("1、2个体力丹消耗（".concat(o.tld, "/30积分）")),
            a.push("2、乾坤八卦（".concat(o.qkbg, "/15积分）")),
            a.push("3、三国鸭（".concat(o.sgy, "/15积分）")),
            a.push("4、猜拳(美人计)（".concat(o.cq, "/15积分）")),
            a.push("5、副本任务（".concat(o.fb, "/20积分）")),
            a.push("6、宴请副将（".concat(o.yqfj, "/10积分）")),
            a.push("7、在线时长60分钟（".concat(o.actTime, "/20积分）")),
            a.push("8、击败玩家（".concat(o.killPlayer, "/10积分）")),
            a.push("9、签到（".concat(o.sign, "/10积分）")),
            a.push("10、挖宝（".concat(o.wb, "/5积分）"));
          for (var r = void 0, i = 0; i < a.length; i++) {
            (r = { itemName: { text: a[i] } }), this.array.push(r);
          }
          (this.list_score_point.visible = !0),
            (this.list_score_point.dataSource = this.array);
        } else {
          for (
            var a = Constants.getScoreData(), r = void 0, i = 0;
            i < a.length;
            i++
          ) {
            var s = a[i];
            (r = {
              itemName: {
                text: i + 1 + "、" + s.name + "    (" + s.reward + ")",
              },
            }),
              this.array.push(r);
          }
          (this.list_score_point.visible = !0),
            (this.list_score_point.dataSource = this.array);
        }
        this.dealTodayReward();
      }),
      (t.prototype.dealCurrentScoreDone = function (e, t) {
        var o;
        return (
          t.alias === e.tld
            ? (o = "(".concat(t.tld, "/30)积分"))
            : "qkbg" === t.alias
            ? (o = "(".concat(3 * t.qkbg, "/15)积分"))
            : "sgy" === t.alias
            ? (o = "(".concat(3 * t.sgy, "/15)积分"))
            : "cq" === t.alias
            ? (o = "(".concat(t.cq, "/15)积分"))
            : "fb" === t.alias
            ? (o = "(".concat(t.fb, "/20)积分"))
            : "yqfj" === t.alias
            ? (o = "(".concat(t.yqfj, "/10)积分"))
            : "actTime" === t.alias
            ? (o = "(".concat(t.actTime, "/20)积分"))
            : "killPlayer" === t.alias
            ? (o = "(".concat(t.killPlayer, "/10)积分"))
            : "sign" === t.alias
            ? (o = "(".concat(t.sign, "/10)积分"))
            : "wb" === t.alias && (o = "(".concat(t.wb, "/5)积分")),
          o
        );
      }),
      (t.prototype.scoredDataWeekData = function (e) {
        if (5324 == e.act_id) {
          this.weekListArr = [];
          for (var t = void 0, o = 0; o < e.data.length; o++) {
            (t = {
              item_score_week: {
                text:
                  o +
                  1 +
                  "、" +
                  (r = e.data[o]).name +
                  "（" +
                  r.roleId +
                  ")   " +
                  r.score +
                  "分",
              },
            }),
              this.weekListArr.push(t);
          }
          (this.list_score_week_rank.visible = !0),
            (this.list_score_week_rank.dataSource = this.weekListArr);
        } else if (5325 == e.act_id) {
          this.weekListArr = [];
          for (var t = void 0, o = 0; o < e.data.length; o++) {
            var r = e.data[o];
            (t = {
              item_score_week: {
                text:
                  o +
                  1 +
                  "、" +
                  r.name +
                  "（" +
                  r.roleId +
                  ")   " +
                  r.score +
                  "分",
              },
            }),
              this.weekListArr.push(t);
          }
          (this.list_score_week_rank.visible = !0),
            (this.list_score_week_rank.dataSource = this.weekListArr),
            (this.label_score_myRank.text = "当前 " + e.more + " 名");
        }
      }),
      (t.prototype.onScoredPointedBackFn = function () {
        "" == this.currentViewName
          ? this.removeSelf()
          : "view_week_rank" == this.currentViewName &&
            ((this.currentViewName = ""), this.initData(), this.initUI());
      }),
      (t.prototype.shwoHomeTitle = function () {
        "" == this.currentViewName
          ? (this.label_scorePoint_title.text = "每日活跃积分")
          : "view_week_rank" == this.currentViewName &&
            (this.label_scorePoint_title.text = "积分周榜");
      }),
      (t.prototype.onTabScorePointAction = function (e) {
        "item0" == e.target.name
          ? WebSocketService.send({ c: 5325, d: { roleId: Global.roleId } })
          : "item1" == e.target.name &&
            WebSocketService.send({ c: 5324, d: { roleId: Global.roleId } });
      }),
      (t.prototype.onDidRewardListClick = function (e) {
        if ("" != e.target.name) {
          var t,
            o = this.list_today_score_reward.selectedItem;
          o.score >= 30 && o.score < 60
            ? (t = 1)
            : o.score >= 60 && o.score < 90
            ? (t = 2)
            : o.score >= 90 && o.score < 120
            ? (t = 3)
            : o.score >= 120 && o.score < 150
            ? (t = 4)
            : o.score >= 150 && (t = 5),
            WebSocketService.send({
              c: 5323,
              d: { roleId: Global.roleId, rewardLvl: t },
            });
        }
      }),
      (t.prototype.onRewardSelectedHandler = function (e, t) {
        if (!(t > this.rewardsListArr.length)) {
          e.getChildByName("item_reward");
          var o = e.getChildByName("item_lingqu"),
            r = this.rewardsListArr[t];
          console.log(
            "this.todayScore:" + this.todayScore + "   item.score:" + r.score
          ),
            this.todayScore >= r.score ? (o.visible = !0) : (o.visible = !1);
        }
      }),
      (t.prototype.scoredRewardResultData = function (e) {
        ToastView.toastView(e.msg);
      }),
      (t.prototype.onScoreWeekIntroAction = function () {
        NormalNewDialog.showNewNormalDialog(
          "周榜奖励",
          "第1名奖励：5000金币\n\n第2名奖励：4000金币\n\n第3名奖励：2500金币\n\n第4-6名奖励：1500金币\n\n第7-10名奖励：1000金币",
          this,
          this.onNoUseFn,
          null,
          "排名依据积分、活跃度、在线时长等多维度因素"
        );
      }),
      (t.prototype.onNoUseFn = function () {}),
      t
    );
  })(ui.common.ScoredPointHomeViewUI);
